<!--
 * @Description: 
 * @Date: 2023-04-02 13:56:13
 * @LastEditTime: 2023-04-03 23:00:03
 * @Author: Black
 * @FilePath: \store_admin\src\components\AsideList.vue
-->
<template>
  <div class="aside_list" :class="{ 'active': active }">
    <span class="truncate">
      <slot></slot>
    </span>
    <el-button class="ml-auto px-1" text type="primary" size="small" @click.stop="$emit('edit')">
      <el-icon :size="12">
        <Edit />
      </el-icon>
    </el-button>

    <!-- stop阻止冒泡 -->
    <span @click.stop="()=>{}">
      <el-popconfirm title="是否要删除该分类吗?" width="200px" confirmButtonText="确认" cancelButtonText="取消"
        @confirm="$emit('delete')">
        <template #reference>
          <el-button text class="px-1" type="primary" size="small">
            <el-icon :size="12">
              <Close />
            </el-icon>
          </el-button>
        </template>
      </el-popconfirm>
    </span>

  </div>
</template>

<script setup>

defineProps({
  active: {
    type: Boolean,
    default: false
  }
})

defineEmits(["edit", "delete"])

</script>

<style scoped>
.aside_list {
  border-bottom: 1px solid #f4f4f4;
  cursor: pointer;
  @apply flex items-center p-3 text-sm text-gray-600;
}

.aside_list:hover,
.active {
  @apply bg-violet-50;
}
</style>